"""
插件注册 && 插件相关配置
"""
from config.cache import RedisClient
from config.const import RedisConst
from flask_sqlalchemy import SQLAlchemy
from raven.contrib.flask import Sentry

db = SQLAlchemy()
sentry = Sentry()
redis_client = RedisClient(prefix=RedisConst.REDIS_PREFIX).client()


def register_api(blueprint, *args, errors=None, **kwargs):
    from flask_restful import Api

    if errors is None:
        errors = {"InternalServerError": {'errmsg': 'internal error', 'errcode': 500}}
    blueprint = Api(blueprint, *args, errors=errors, **kwargs)
    return blueprint
